package hys.videoplayerdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import hys.videoplayerdemo.video_sdk.video.VideoAdSlot;

import static hys.videoplayerdemo.video_sdk.constant.SDKConstant.VIDEO_URL;

public class MainActivity extends AppCompatActivity implements VideoAdSlot.AdSDKSlotListener {
    private RelativeLayout mVieoContentLayout;
    private String videoUrl = VIDEO_URL;
    //the ad container
    private VideoAdSlot mAdSlot;
    //the listener to the app layer
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mVieoContentLayout = (RelativeLayout) findViewById(R.id.video_layout);
//       开放 播放器地址,videoUrl的接口
        mAdSlot = new VideoAdSlot( this);//构造方法注册
//        mAdSlot.setmSlotListener(this);//set(this)方法注册；
 }

    @Override
    public String getUrlVideo() {
        return videoUrl;
    }

    @Override
    public ViewGroup getAdParent() {
        Log.i("mParentView", "VideoAdSlot: "+2);
        return mVieoContentLayout;
    }

    @Override
    public void onAdVideoLoadSuccess() {
        if (mAdSlot != null) {
            Log.i("MainActivity", "onAdVideoLoadSuccess: 视频加载成功");
        }
    }

    @Override
    public void onAdVideoLoadFailed() {
        if (mAdSlot != null) {
            Log.i("MainActivity", "onAdVideoLoadSuccess: 视频加载失败");
        }
    }

    @Override
    public void onAdVideoLoadComplete() {
        Log.i("MainActivity", "onAdVideoLoadComplete: 视频播放结束");
    }
}
